#ifndef WS2812_H__
#define WS2812_H__

#include <stdbool.h>
#include "dma.h"
#include "tim.h"

typedef struct WS2811_Handle WS2811_HandleTypeDef;

struct WS2811_pf
{
	void (*setColor)(WS2811_HandleTypeDef* hsw2811, uint8_t startNum, uint8_t endNum, uint8_t R, uint8_t G, uint8_t B);
};

struct WS2811_Status
{
	TIM_HandleTypeDef 	*htim;
	bool 				initBool;
	uint8_t 			ledNum;
	uint16_t 			*txData;
	uint32_t			pwmChannel;
};

struct WS2811_Handle
{
	struct WS2811_pf		*pf;
	struct WS2811_Status 	status;
};

void WS2811_init(WS2811_HandleTypeDef *hsw2811, TIM_HandleTypeDef *htim, uint32_t pwmChannel, uint8_t ledNum, uint16_t* sTxData, uint16_t sTxDataLen);

#define WS2812_REFRESH_DATA_NUM (20 * 24)	// 用来发几十秒低电平复位

#define WS2811_Init(WS2811, htim, pwmChannel, ledNum)	\
static uint16_t WS2811##_RxData[ledNum * 24 + WS2812_REFRESH_DATA_NUM] = {0};\
WS2811_init(&WS2811, &htim, pwmChannel, ledNum, WS2811##_RxData, ledNum * 24 + WS2812_REFRESH_DATA_NUM)


#endif

